package com.zking.controller;

import com.zking.service.UploadService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/*
@Value 可以获取配置中的属性值：@Value("${属性的名字}")

 */
@RestController @RequiredArgsConstructor
public class MyController1 {
    @Value("${port}")
    private int port1;
    @Value("${server.port}")
    private int port2;
    @Value("${server.servlet.port}")
    private int port3;
    
    // 自动注入依赖
    private final UploadService uploadService;
    
    @GetMapping("/test")
    public String test() {
        return "原神启动！- 666";
    }
    
    @GetMapping("/t1")
    public String t1() {
        return String.format("port1=%s, port2=%s, port3=%s",
                port1, port2, port3);
    }
    
    @GetMapping("/t2")
    public String t2() {
        return uploadService.test();
    }
}
